Skip to content

Conversation

bhouston
Copy link
Member

@bhouston bhouston commented Mar 5, 2025

Add CLI Startup Profiling Feature

This PR adds a profiling feature to the CLI to help diagnose the slow startup times on Windows compared to MacOS (Issue #100).

Changes

  1. Added a --profile flag to enable performance profiling
  2. Created a performance tracking module that:
    • Measures timing of key initialization steps
    • Reports detailed timing information
    • Provides platform-specific diagnostics on Windows
  3. Added a test-profile command to easily test the profiling feature
  4. Optimized Sentry initialization to only run when needed

How to Use

Run any command with the --profile flag to see timing information:

# Basic usage
mycoder --profile --help

# With a specific command
mycoder --profile test-profile

The profiling output shows:

  • Timing for each initialization step
  • Total startup time
  • On Windows: additional platform diagnostics to help identify bottlenecks

Example Output

📊 Performance Profile:
=======================
Module initialization: 10.12ms (10.12ms)
After imports: 150.34ms (140.22ms)
Main function start: 269.99ms (119.65ms)
After dotenv config: 270.10ms (0.11ms)
After Sentry init: 297.57ms (27.48ms)
Before package.json load: 297.57ms (0.00ms)
After package.json load: 297.78ms (0.21ms)
Before yargs setup: 297.78ms (0.00ms)
After yargs setup: 401.45ms (103.67ms)
Total startup time: 401.45ms
=======================

Next Steps

Based on the profiling data, we can identify and optimize the slowest parts of the initialization process, particularly focusing on Windows-specific optimizations.

Closes #100

@bhouston
Copy link
Member Author

bhouston commented Mar 5, 2025

I've added the profile option to the persistent config file as requested. This allows you to enable profiling permanently on your development machine.

How to Use

You can enable profiling in your config with:

# Enable profiling in config
mycoder config set profile true

# Disable profiling in config
mycoder config set profile false

Once enabled in the config, all mycoder commands will automatically show profiling information without needing the --profile flag.

Fix double yargs initialization in CLI profiling feature
@bhouston bhouston merged commit a418b57 into main Mar 5, 2025
1 check passed
Copy link

🎉 This PR is included in version mycoder-v1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bhouston bhouston deleted the feature/cli-profiling branch March 12, 2025 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance: Slow CLI Startup Times on Windows Compared to MacOS

1 participant